﻿
using System.Data;
using Oracle.ManagedDataAccess.Client;


namespace MyTools.DataDic.Utils
{
    public class OracleHelper
    {
        private static string _connNow = "User Id=用户名;Password=密码;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=OracleIP地址)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=服务名称)))";
        public static DataTable ExecuteNowDataTable(string sql, params OracleParameter[] parameters)
        {
            using (OracleConnection conn = new OracleConnection(_connNow))
            {
                conn.Open();
                using (OracleCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    cmd.Parameters.AddRange(parameters);
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd);
                    DataTable datatable = new DataTable();
                    adapter.Fill(datatable);
                    return datatable;
                }
            }
        }
    }


}
